package com.example.user.controller.contest;

import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.R;
import com.example.common.core.domain.TableDataInfo;
import com.example.user.domain.contest.dto.ContestQueryDTO;
import com.example.user.domain.contest.dto.ContestRankDTO;
import com.example.user.service.contest.ContestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/contest")
public class ContestController extends BaseController {

    @Autowired
    private ContestService contestService;
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(ContestQueryDTO contestQueryDTO) {
        return getDataTable(contestService.list(contestQueryDTO));
    }

    @GetMapping("/semiLogin/redis/list")
    public TableDataInfo redisList(ContestQueryDTO contestQueryDTO) {
        return contestService.redislist(contestQueryDTO);
    }

    @GetMapping("/rank/list")
    public TableDataInfo rankList(ContestRankDTO contestRankDTO) {
        return contestService.rankList(contestRankDTO);
    }

    @GetMapping("/getFirstQuestion")
    public R<String> getFirstQuestion(Long contestId) {
        return R.ok(contestService.getFirstQuestion(contestId));
    }

    @GetMapping("/preQuestion")
    public R<String> preQuestion(Long contestId,Long questionId) {
        return R.ok(contestService.preQuestion(contestId,questionId));
    }

    @GetMapping("/nextQuestion")
    public R<String> nextQuestion(Long contestId,Long questionId) {
        return R.ok(contestService.nextQuestion(contestId,questionId));
    }

}
